package base;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.junit.Test;

public class StringRegexTest {
   
	@Test
	public void StringRegex(){
	//String s ="windows7";
	//String regx="windows(?!7)"; //结果为 windows
//		String s="zoooz";
//		String regx="zo*";  //结果为：zooo
		String s="2017-2-20";
		String regx="\\S*";  
		Pattern pattern= Pattern.compile(regx);
	 Matcher matcher=  pattern.matcher(s);
   if(matcher.find()){
	  System.out.println(matcher.group(0));
	  System.out.println(matcher.group(1));
	 // System.out.println(matcher.group(2));
   }else{
	   System.out.println("未找到");
   }	
	}
	
	@Test
	public void StringRegx(){
		String s="adax";
		String regx="x$";
		Pattern pattern =Pattern.compile(regx);
		Matcher matcher= pattern.matcher(s);
		System.out.println(matcher.find());
	}
	
}
